package br.com.banco.control;

import br.com.banco.Logon;
import br.com.banco.model.Cliente;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * Servlet implementation class ValidaFraseSecreta
 */
public class ValidaFraseSecreta extends HttpServlet {

    private static final long serialVersionUID = 1L;

    /**
     * @see HttpServlet#HttpServlet()
     */
    public ValidaFraseSecreta() {
        super();
    }

    /**
     * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    }

    /**
     * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
     *      response)
     */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        final Logon logon = new Logon();
        String fraseSecreta = request.getParameter("fraseSecreta");
        boolean isValido = logon.validaFraseSecreta(fraseSecreta);

        if (isValido) {
             // TODO: Busca o cliente corrêntista que corrêsponde a conta.
             request.getSession().setAttribute("usuario", new Cliente());
        }

       

        request.getRequestDispatcher("menuOpcoes.jsp").forward(request, response);
    }
}
